package com.monodev.mvc.controller;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;

import javax.servlet.http.HttpServletRequest;
import java.util.HashMap;
import java.util.Map;

/**
 * Created by Administrator on 2017/11/21 0021.
 */
@Controller
public class ProductController {

    @RequestMapping("/addProduct")
    public ModelAndView addProduct(HttpServletRequest request){ //EL表达式
        System.out.println("插入数据库");
        String name = request.getParameter("name");
        String price = request.getParameter("price");
        ModelAndView view = new ModelAndView("showProduct");
        HashMap<String, Object> hashMap = new HashMap<>();


        hashMap.put("key", "我家大门钥匙");
        hashMap.put("key2", "我家主卧钥匙");
        view.addAllObjects(hashMap);
        view.addObject("name", name);
        view.addObject("price", price);
        return view;
    }

}
